Skip to content

Conversation

@bo-ram-bo-ram
Copy link
Member

@bo-ram-bo-ram bo-ram-bo-ram commented Jan 28, 2025

Pull request

Related issue

resolve #27

Motivation and context

  • web 프로덕트이기 때문에 보안을 신경쓰기 위해 client에게 kakao 인가코드를 넘겨받아서 kakao access token을 만들고 해당 token으로 access token과 refresh token을 생성하였습니다.

  • 간결한 코드와 의존성을 낮추기 위해 Feign 클라이언트를 통해 Kakao 인증 API와 통신하여 액세스 토큰을 가져오도록 구현했습니다.

  • 추후 새로운 소셜 로그인이 확장될 것을 대비하여 Request Body에 어떤 Social Type인지 받도록 하였습니다! 받은 Social Type이 Kakao일 경우에 KakaoSocialService로 요청을 보내는 switch - case 문을 사용하였습니다! 또, KakaoSocialService는 SocialService 인터페이스를 구현하고 있습니다. 후에 구글이나 네이버 로그인을 구현하게 될 때 이 인터페이스를 상속받아 구현하도록 설계하였습니다.

  • 카카오 공식문서를 참고하여 구현했습니다. 이해하실 때 flow와 kakao access token을 통해 정보를 얻어올 때 getLoginDto에 담기는 정보와 변수를 확인하실 때 참고하시면 좋을 것 같습니다.

  • 로컬 컴퓨터에 Redis가 설치되어 있지 않을경우 실행되지 않습니다! Redis 설치해주세요!

Solution

How has this been tested

image image image ![jootalkpia_default](https://github.com/user-attachments/assets/3ce04477-1f9f-4938-8229-5dbd619f6fee)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@bo-ram-bo-ram bo-ram-bo-ram self-assigned this Jan 28, 2025
@bo-ram-bo-ram bo-ram-bo-ram added ✨ Feature 기능 추가 🎮 BE 백엔드 무조건 스프린트내에 해야하는 것들 labels Jan 28, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localhost로 되어있는 부분 경로를 환경변수처리하면 나중에 배포 환경에 적합하게 바꿀 때 편할 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 좋은 부분이에요 감사합니다! 다만 redirectUri를 request에 클라이언트가 보내주시는건데 @Schema를 통해 예시 들어드리는 부분입니당! 저희가 따로 처리하는 부분은 아닌데 어떻게할까요??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 경우에는 게이트웨이에서 passport를 주지 않고 헤더를 직접 확인하는 방식으로 하는걸까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passport는 토큰을 기반으로 만들어지게 되는데요. 회원가입 부분은 토큰이 없는 상태로 응답해야하는 api 입니당!

Copy link
Member

@mirlee0304 mirlee0304 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다! 이번 pr에 대해 상세히 설명해주신 부분 중에서 서비스명만 확인해주세용!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리프레시 토큰도 전달하는 이유는 뭔가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 구현한 방식은 최초 회원가입 / 로그인시 응답에 access token과 refresh token을 같이 내려주고 access token을 가지고 요청을 보낼때마다 사용하고 이때 access token이 만료됐다는 에러를 서버가 반환하면 refresh token을 서버로 보내고 새로운 access token을 반환하는 형식을 사용했기 때문입니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 해당 방식으로 구현 시 리프레시 토큰이 노출될 위험에 대해서는 괜찮은 걸까요?

Copy link
Member Author

@bo-ram-bo-ram bo-ram-bo-ram Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

악의있는 탈취자는 통신이 빈번한 Access Token을 탈취할 가능성이 높고 해당부분 방지를 위해 refresh token을 도입했습니다 ! 그리고 말씀해주신 부분에 대한 우려로 rtr기법이 존재하는데 이부분은 리프레시 토큰이 탈취된 상황을 고려하는것은 추후의 일이라고 하셨던 캠프장님 말을 참고해서 추후 고도화 시 도입해보겠습니다 !

@bo-ram-bo-ram bo-ram-bo-ram changed the title 인증서버 내 kakao social logi을 통한 회원가입 인증서버 내 kakao social login을 통한 회원가입 Jan 29, 2025
@bo-ram-bo-ram bo-ram-bo-ram merged commit 73da001 into dev Jan 30, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 추가 무조건 스프린트내에 해야하는 것들 🎮 BE 백엔드

Projects

None yet

Development

Successfully merging this pull request may close these issues.

인증서버 내 kakao social 연동을 통한 회원가입

3 participants